(function(){
    function formartUrl() {
        var kvArr = location.search.substr(1).split('&');
        var kvObj = {};
        for (var i = 0; i < kvArr.length; i++) {
            // 再把每个元素以=分割
            var temp = kvArr[i].split("=");
            kvObj[temp[0]] = temp[1];
        }
        return kvObj;
    }
    $(".mmb_foot1_module a:nth-child(3)").click(function(){
        $("html").scrollTop(0);
    });

    var cateid = formartUrl().productid;
    // 1
    $.ajax({
        type: "get",
        url: "http://193.112.55.79:9090/api/getproduct",
        data: {productid:cateid},
        dataType: "json",
        success: function (res) {
            var breadtit = res.result[0].productName.split(" ");
            console.log(res);  
            // console.log(cid);
            var data2 = '<div class=\"noneis\"><a href=\"javascript:;\">比价购买</a><a href=\"javascript:;\">产品参数</a><a href=\"javascript:;\">评价<span class=\"allprice\"></span></div>';
            var data = '<div class=\"details_contop\"><span>'+res.result[0].productName+'</span><div class=\"img\">'+res.result[0].productImg+'</div></div>'+data2+res.result[0].bjShop;
            $(".details_con").html(data);
            // $(".bread_list").attr("href","./brandTitle_list.html?brandtitleid="+res.result[0].categoryId);
            $(".breadnav_l").append(breadtit[0]);
        }
    });

    $.ajax({
        type: "get",
        url: "http://193.112.55.79:9090/api/getproductcom",
        data: {productid:cateid},
        dataType: "json",
        success: function (res) {
            var data2 = template("details_temp2",res.result);
            $(".details_plcon").html(data2);
        }
    });
})();